package com.yatang.yiliao.app.activities;


import android.content.SharedPreferences;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.view.ViewPager;
import android.os.Bundle;
import android.view.Window;
import com.yatang.yiliao.app.Constants;
import com.yatang.yiliao.app.R;
import com.yatang.yiliao.app.adapters.FragmentAdapter;
import com.yatang.yiliao.app.fragments.TutorialImageFragment;
import com.yatang.yiliao.app.fragments.TutorialJumpFragment;


import java.util.LinkedList;
import java.util.List;

public class TutorialActivity extends FragmentActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_tutorial);
        SharedPreferences sp = getSharedPreferences(Constants.APP_DATA, MODE_PRIVATE);
        SharedPreferences.Editor editor = sp.edit();
        editor.putBoolean(Constants.APP_SHOW, true);
        editor.commit();
        ViewPager viewPager = (ViewPager) findViewById(R.id.tutorial_viewPager);
        List<Fragment> fragments = new LinkedList<Fragment>();
        //TODO 添加教程第一页
        Fragment fragment = new TutorialImageFragment();
        Bundle args = new Bundle();
        args.putInt(Constants.ARG_IMAGE_LAYOUTID, R.layout.fragment_tutorial_image1);
        fragment.setArguments(args);
        fragments.add(fragment);
        //TODO 添加教程第二页
        fragment = new TutorialImageFragment();
        args = new Bundle();
        args.putInt(Constants.ARG_IMAGE_LAYOUTID, R.layout.fragment_tutorial_image2);
        fragment.setArguments(args);
        fragments.add(fragment);
        Fragment jumpFragment = new TutorialJumpFragment();
        args = new Bundle();
        args.putInt(Constants.ARG_IMAGE_LAYOUTID, R.layout.fragment_tutorial_jump);
        jumpFragment.setArguments(args);
        fragments.add(jumpFragment);
        FragmentAdapter adapter = new FragmentAdapter(getSupportFragmentManager(), fragments);
        viewPager.setAdapter(adapter);
    }
}
